# coding:utf8
from django.db import models
from DjangoUeditor.models import UEditorField


# Create your models here.

class Article(models.Model):
    title = models.CharField(verbose_name="博客标题", max_length=100)
    category = models.CharField(verbose_name="博客标签", max_length=50)
    digest = models.CharField(verbose_name="摘要", max_length=200, default=None)
    pub_date = models.DateTimeField(verbose_name="发布日期", auto_now_add=True, editable=True)  # 博客发布日期
    update_time = models.DateTimeField(verbose_name="更新时间", auto_now=True, null=True)  # 更新时间
    content = UEditorField(verbose_name="文章正文", height=300, width=800, default=u'', blank=True,
                           imagePath="uploads/blog/images/",
                           toolbars='besttome', filePath='uploads/blog/files/')  # 博客文章正文

    def __str__(self):
        """定义每个数据对象的显示信息"""
        return self.title

    class Meta:
        ordering = ['-pub_date']  # 发布日期降序排列
        verbose_name = "文章"  # 在admin站点中显示的名称
        verbose_name_plural = verbose_name  # 显示的复数名称



